﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using MyMES.Domain.zyy;
using MyMES.Error;
using MyMES.Writer.API.Application.Commends.Productionwork;

namespace MyMES.Writer.API.Controllers.Productionwork
{
    [Route("api/[controller]")]
    [ApiController]
    public class ProductionworkController : ControllerBase
    {
        private readonly IMediator med;

        public ProductionworkController(IMediator med)
        {
            this.med = med;
        }




        /// <summary>
        /// 创建生产工单--任务工单
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        /// 

        [HttpPost]
        public async Task<APIResult<WorkOrder>> CreateProductionwork(CreateProductionworkCommends request, CancellationToken cancellationToken)
        {
            return await med.Send(request, cancellationToken);
        }


        /// <summary>
        /// 更新生产工单
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        /// 
        [HttpPut]
        public async Task<APIResult<WorkOrder>> UpdataProductionwork(UpdataProductionworkCommends request, CancellationToken cancellationToken)
        {
            return await med.Send(request, cancellationToken);
        }
    }
}
